#include<iostream>
using namespace std;
typedef long long LL;
const int N = 1e5 + 10;
LL s[N];
int n, m;
int main()
{
	cin >> n >> m;
	for (int i = 1; i <= n; i++) {
		int x;
		cin >> x;
		s[i] = s[i - 1] + x;
	}
	while (m--) {
		int l, r;
		cin >> l >> r;
		cout << s[r] - s[l - 1] << endl;
	}
	return 0;
}